/*
 * 文件名：ResourceUtil.java
 * 版权：Copyright 2006-2011 AsiaInfo Tech. Co. Ltd. All Rights Reserved. 
 * 描述： ResourceUtil.java
 * 修改人：齐鹏飞
 * 修改时间：2011-9-5
 * 修改内容：新增
 */
package com.fengxing.ams.pub.util;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.XMLConfiguration;

import com.fengxing.ams.pub.UtilityException;

/**
 * 系统配置工具类
 * 
 * @author 齐鹏飞
 * @version CTMS V100R001 2011-9-5
 * @since CTMS V100R001C01
 */
public class ResourceUtil {

	/**
	 * 
	 * 根据ConfigID加载配置
	 * 
	 * @param configID
	 *            配置文件名称
	 * @return 配置
	 */
	public static Configuration loadProps(String configID) {
		Configuration config;
		try {
			config = new PropertiesConfiguration(Thread.currentThread()
					.getContextClassLoader().getResource(configID));
		} catch (ConfigurationException e) {
			throw new UtilityException(e);
		}

		return config;
	}

	/**
	 * 
	 * 根据ConfigID加载配置
	 * 
	 * @param configID
	 *            配置文件名称
	 * @return 配置
	 */
	public static XMLConfiguration loadXmlProps(String configID) {
		XMLConfiguration config;
		try {
			config = new XMLConfiguration(Thread.currentThread()
					.getContextClassLoader().getResource(configID));
		} catch (ConfigurationException e) {
			throw new UtilityException(e);
		}

		return config;
	}
}
